//活动事件表
var eventApp = new Vue({
    el:'#eventApp',
    data:{
        event_arr:[],
        pageInfo:{},
        userevent_arr:[],
        sendevent_arr:[],
    },
    methods:{
        loadEvents:function(pageNum) {
            if (!pageNum) {
                //默认查询第一页
                pageNum = 1;
            }
            axios.get("/eventlist",{
                params:{
                    pageNum:pageNum,
                }
            }).then(function (response) {
                eventApp.event_arr = response.data.list;
                console.log(eventApp.event_arr);
                eventApp.pageInfo = response.data;
            }).catch(function (err) {
                alert(err);
            })
        },
        deleteById:function(id){
            axios.get("/deleteEventById?id="+id).then(function (response) {
                location.reload();//删除完之后刷新
            }).catch(function (err) {
                alert(err);
            })
        },

        /*
        loadUserEventsById:function(pageNum) {
            if (!pageNum) {
                //默认查询第一页
                pageNum = 1;
            }
            axios.get("/userEventsById?userId="+userId,{
                params:{
                    pageNum:pageNum,
                }
            }).then(function (response) {
                eventApp.userevent_arr = response.data.list;
                console.log(eventApp.userevent_arr);
                eventApp.pageInfo = response.data;
            }).catch(function (err) {
                alert(err);
            })
        },
        */
        loadUserEventsById:function(pageNum) {
            if (!pageNum) {
                //默认查询第一页
                pageNum = 1;
            }
            axios.get("/userEventsById",{
                params:{
                    pageNum:pageNum,
                }
            }).then(function (response) {
                eventApp.userevent_arr = response.data.list;
                console.log(eventApp.userevent_arr);
                eventApp.pageInfo = response.data;
            }).catch(function (err) {
                alert(err);
            })
        },

        /*
       loadSendEventsById:function(pageNum) {
           if (!pageNum) {
               //默认查询第一页
               pageNum = 1;
           }
           axios.get("/sendEventsById?userId="+userId,{
               params:{
                   pageNum:pageNum,
               }
           }).then(function (response) {
               eventApp.sendevent_arr = response.data.list;
               console.log(eventApp.userevent_arr);
               eventApp.pageInfo = response.data;
           }).catch(function (err) {
               alert(err);
           })
       },
       */

        loadSendEventsById:function(pageNum) {
            if (!pageNum) {
                //默认查询第一页
                pageNum = 1;
            }
            axios.get("/sendEventsById",{
                params:{
                    pageNum:pageNum,
                }
            }).then(function (response) {
                eventApp.sendevent_arr = response.data.list;
                console.log(eventApp.userevent_arr);
                eventApp.pageInfo = response.data;
            }).catch(function (err) {
                alert(err);
            })
        },
    },
    created:function () {
        console.log("执行了方法");
        this.loadEvents();
        this.loadUserEventsById();
        this.loadSendEventsById();
    }
});